# -*- coding: utf8 -*-
import requests
import shutil
import os

base_dir = os.path.dirname(os.path.abspath(__file__))
sourcedir = os.path.join(base_dir, "files/package")
destdir = os.path.join(base_dir,"files/html")
def exist_dir(dirname):
    if not os.path.exists(dirname):
        os.makedirs(dirname)
exist_dir(base_dir)
exist_dir(sourcedir)
header = {"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"}
# 1.下载文件
file_url = 'https://files.cnblogs.com/files/wupeiqi/HtmlStore.zip'
res = requests.get(url=file_url, headers=header)
data = res.content
filename = os.path.join(sourcedir,file_url.rsplit("/",1)[-1])
with open(filename,mode="wb") as f:
    f.write(data)
shutil.unpack_archive(filename,destdir,format="zip")

# 2.将下载的文件保存到当前执行脚本同级目录下 /files/package/ 目录下（且文件名为HtmlStore.zip）

# 3.在将下载下来的文件解压到 /files/html/ 目录下